﻿<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>Klass继承示例</title>
	</head>
	<body>
		<script type="text/javascript">
		var Class = function(){
			var klass = function(){
				//定义类的初始化方法
				this.init.apply(this,arguments);
			}
			
			klass.prototype.init = function(){}
			klass.fn = klass.prototype;
			//定义类的别名
			klass.fn.parent = klass;
			//给类添加属性
			klass.extend = function(obj){
				var extended = obj.extended;
				for(var i in obj){
					klass[i] = obj[i];
				}
				if(extended) extended(klass)
			};
			
			klass.include = function(obj){
				var included = obj.included;
				for(var i in obj){
					klass.fn[i] = obj[i];
				}
				if(included) included(klass)
			};
			
			return klass;
		}
		
		</script>
	</body>
</html>